package com.example.hao.frameanimation;

import android.graphics.drawable.AnimationDrawable;
import android.graphics.drawable.Drawable;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;

public class MainActivity extends AppCompatActivity implements View.OnClickListener{

    private View v1;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();

        //The 55-kilometer bridge is expected to cut down the travel time between Hong Kong,Zhuhai and Macao from three hours to less than an hour.
        //The party kicked off around 9 last night.It was so fun.
        //We are going to kick off the meeting tomorrow at 10 o'clock.Be on time!
        //Have you been to a meeting or a party recently? If yes, what time did it kick off?
        //Add oil is an expression that has gained a lot of currency in Hong Kong in the last few years.A literal translation of the Cantonese phrase ga you.
        //long time no see   Jiaozi HongBao
        //上面是随便敲的,不要在意...
    }

    private void initView() {
        v1 = findViewById(R.id.v1);
        v1.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.v1:
                AnimationDrawable background = (AnimationDrawable) v.getBackground();
                if (!background.isRunning()){
                    background.start();
                }else {
                    background.stop();
                }
                break;
        }
    }
}
